package md.lanjing.com.module_mine.contact;

import android.content.Context;

import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.util.ToastUtils;



import com.lxh.baselibray.constant.Constant;

import md.lanjing.com.module_mine.api.MineApiService;
import md.lanjing.com.module_mine.bean.RealNameAuthenticationRequest;
import md.lanjing.com.module_mine.bean.RealNameAuthenticationResponse;
import retrofit2.Call;
import retrofit2.Response;

public class RealNameAuthenContact {
    public static class RealNameAuthenPresent extends BasePresent<IRealNameAuthenView> {
        public void realNameAuthen(final Context context, String imgF, String imgB, String realName, String identityNum){
            MineApiService service= ServiceGenerator.createService(MineApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            RealNameAuthenticationRequest request=new RealNameAuthenticationRequest(realName,identityNum,imgF,imgB,userId);
            service.realNameAuthenticated(request).enqueue(new NetCallBack<RealNameAuthenticationResponse>() {
                @Override
                public void onSuccess(Call<RealNameAuthenticationResponse> call, Response<RealNameAuthenticationResponse> response) {
                    if (getView()!=null){
                        getView().getRealNameAuthenData(response);
                    }
                }

                @Override
                public void onFailed() {
                    ToastUtils.showLongToast(context,"网络请求异常");
                }
            });

        }
    }

    public interface IRealNameAuthenView extends IBaseView {
            void getRealNameAuthenData(Response<RealNameAuthenticationResponse> response);
    }
}
